package com.maxd.service.Commodity;


import com.maxd.model.CommodityExquisite;
import com.maxd.respository.commodity.CommodityExquisiteJpaRepository;
import com.maxd.respository.commodity.CommodityExquisiteRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 精选商品
 */
@Service
public class CommodityExquisiteServiceImpl implements CommodityExquisiteService {

    /** 精选商品 */
    @Autowired
    private CommodityExquisiteJpaRepository commodityExquisiteJpaRepository;
    /** 精选商品 */
    @Autowired
    private CommodityExquisiteRepository commodityExquisiteRepository;


    @Override
    public Page<CommodityExquisite> selectCommodityExquisite(Pageable pageable) {
        return commodityExquisiteRepository.selectCommodityExquisite(pageable);
    }

    @Override
    public CommodityExquisite selectById(Long id) {
        return commodityExquisiteRepository.selectById(id);
    }

    @Override
    public List<CommodityExquisite> selectByUserId(Long userId) {
        return commodityExquisiteRepository.selectByUserId(userId);
    }

    @Override
    public CommodityExquisite save(CommodityExquisite commodityExquisite) {
        return commodityExquisiteJpaRepository.save(commodityExquisite);
    }

    @Override
    public void saveAll(List<CommodityExquisite> list) {
        commodityExquisiteJpaRepository.saveAll(list);
    }

    @Override
    public CommodityExquisite update(CommodityExquisite commodityExquisite) {
        return commodityExquisiteJpaRepository.save(commodityExquisite);
    }

    @Override
    public void deleteById(Long id) {
        commodityExquisiteJpaRepository.deleteById(id);
    }

    @Override
    @Transactional
    public void deleteByIdList(String ids) {
        String []id=ids.split(",");
        for(String i:id){
            commodityExquisiteJpaRepository.deleteById(Long.parseLong(i));
        }

    }

}
